package com.hr.牛客网剑指offer;

import java.util.Stack;

/**
 * @author zhz
 * @date 2020/08/22
 **/
public class JZ5_用两个栈实现队列 {
    Stack<Integer> stack1 = new Stack<Integer>();//入栈当出尾
    Stack<Integer> stack2 = new Stack<Integer>();//

    public void push(int node) {
        stack1.add(node);//对列的入栈
    }

    public int pop() {//队列的出栈
        if (stack2.isEmpty()){
            while (!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        if (stack2.isEmpty()){
            return -1;
        }
        return stack2.pop();
    }
}
